/** Author: David Powell
This file produces data for Tables A3 and A4
**/


clear all
set more off
set mat 800
set seed 8721

global dir "/jules/b/dpowell"
global DATA "${dir}/purdue/replication/DATA"
global OUTPUT "${dir}/purdue/replication/output"


use ${DATA}/finaldata if year>=1991 & year<1996


gen oxycodone_rate=1000*oxycodone_SDUD/medicaidb
replace oxycodone_rate=oxycodone_rate*4/numobs_sdud

preserve
gcollapse oxycodone_rate [aw=medicaidb], by(stf) fast
statastates, fips(stf)
gen str99 tmp=proper(state_name)
sort  oxycodone_rate
keep tmp  oxycodone_rate
save ${OUTPUT}/TableA4, replace
restore


preserve
keep if year==1995
gcollapse oxycodone_rate [aw=medicaidb], by(stf) fast
statastates, fips(stf)
gen str99 tmp=proper(state_name)
sort  oxycodone_rate
keep tmp  oxycodone_rate
save ${OUTPUT}/TableA3, replace
restore
